#include <iostream>

using namespace std;

extern "C" {
#include <stdlib.h>
#include <string.h>
#include <errno.h>
}

class error {
public:
        int err;
        void perr();
};

void error::perr(void)
{
        cout << strerror(err) << endl;
}

void foo(int a)
{
        static error e;

        cout << __func__ << "(1)" << endl;

        if (a) {
                e.err = EINTR;
                throw e;
        }

        cout << __func__ << "(2)" << endl;
}

int main(int argc, char **argv)
{
        if (argc != 2) {
                cout << "argment..." << endl;
                return 1;
        }

        int a;
        a = atoi(argv[1]);

        try {
                foo(a);
        }
        catch (error &e) {
                e.perr();
        }

        return 0;
}
